Application program integrity verification method and network device

ABSTRACT

Embodiments of the present disclosure disclose an application program integrity verification method and a network device. The method includes: performing characteristic value calculation on data of an application program when the application program starts, to obtain a first digest of the application program; decrypting a stored digital signature of the application program according to a public key in an embedded key pair to obtain a second digest of the application program, where the digital signature is obtained, according to a private key in the key pair, by signing data of the application program each time the application program is updated, and the key pair is a manufacturer key pair corresponding to the application program; and determining that integrity verification of the application program passes if the first digest and the second digest are the same, otherwise, determining that integrity verification of the application program does not pass.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application is a continuation of U.S. patent application Ser. No.15/594,264, filed on May 12, 2017, which is a continuation ofInternational Application No. PCT/CN2015/086262, filed on Aug. 6, 2015,which claims priority to Chinese Patent Application No. 201410647567.8,filed on Nov. 14, 2014. All of the aforementioned applications arehereby incorporated by reference in their entireties.

TECHNICAL FIELD

Embodiments of the present disclosure relate to an application programintegrity verification method and a network device.

BACKGROUND

With rapid development of the internet, people perform networkoperations such as online transfer and online shopping through theinternet more frequently. Meanwhile, some villains tamper with anapplication program in a network device to steal user privateinformation such as an account number and a password, which poses athreat to property safety of a user. Therefore, a verification onintegrity for an application program is urgently required, to determinewhether the application program is tampered with.

At present, to further ensure integrity of an application program andprevent a villain from tampering with an application program, a securitycentral processing unit (CPU) and a trusted platform module (TPM) chipmay be disposed in a network device. In this way, when a manufacturerpublishes an application program, hash calculation is performed on dataof the application program to obtain a first hash digest of theapplication program, information about the first hash digest is signedby using a manufacturer private key, to obtain a digital signature ofthe application program, the digital signature of the applicationprogram and the data of the application program are packed as a programpackage, and then the program package is published. When downloading theprogram package of the application program, the network device storesthe digital signature in the program package to the TPM chip.Subsequently, when the network device starts the application program,the security CPU in the network device performs hash calculation on thedata of the application program to obtain a second hash digest of theapplication program, obtains the digital signature of the applicationprogram from the TPM chip of the network device, and decrypts theobtained digital signature by using an embedded manufacturer public key,to obtain the first hash digest of the application program. The firsthash digest is compared with the second hash digest. If the two are thesame, it is determined that the application program is not tamperedwith, and integrity verification of the application program passes;otherwise, it is determined that the application program is tamperedwith, and integrity verification of the application program does notpass.

When a vulnerability exists in the application program of the networkdevice, patching needs to be performed on the application program.Patches are generally distributed on multiple data fragments of theapplication program, and the stored digital signature in the TPM chip ofthe network device is obtained by means of signing when the applicationprogram is published, that is, the stored digital signature in the TPMchip is obtained based on original data of the application program.Therefore, data obtained after patching is performed on the applicationprogram is different from the original data, and integrity verificationcannot be performed, based on the digital signature of the originaldata, on the application program obtained after patching is performed.

SUMMARY

Embodiments of the present disclosure provide an application programintegrity verification method and a network device.

Technical solutions are as follows.

According to a first aspect, an application program integrityverification method is provided, where the method includes:

performing characteristic value calculation on data of an applicationprogram when the application program starts, to obtain a first digest ofthe application program;

decrypting a stored digital signature of the application programaccording to a public key in an embedded key pair to obtain a seconddigest of the application program, where the digital signature isobtained, according to a private key in the key pair, by signing data ofthe application program each time the application program is updated,and the key pair is a manufacturer key pair corresponding to theapplication program; and

determining that integrity verification of the application programpasses if the first digest and the second digest are the same, ordetermining that integrity verification of the application program doesnot pass if the first digest and the second digest are different.

With reference to the first aspect, in a first possible implementationmanner of the first aspect, before the performing characteristic valuecalculation on data of an application program when the applicationprogram starts, to obtain a first digest of the application program, themethod further includes:

performing characteristic value calculation on the data of theapplication program when receiving an update completion instruction, toobtain the second digest of the application program;

signing the second digest according to the private key to obtain thedigital signature of the application program; and

storing the digital signature of the application program.

With reference to the first aspect or the first possible implementationmanner of the first aspect, in a second possible implementation mannerof the first aspect, the performing characteristic value calculation onthe data of the application program to obtain the second digest of theapplication program includes:

reading the data of the application program in a memory into a staticrandom access memory SRAM inside a security central processing unit CPU;

reading the data in the SRAM by using a security engine inside thesecurity CPU; and

performing characteristic value calculation on the read data by usingthe security engine, to obtain the second digest of the applicationprogram.

With reference to the first possible implementation manner of the firstaspect or the second possible implementation manner of the first aspect,in a third possible implementation manner of the first aspect, thestoring the digital signature of the application program includes:

storing the digital signature of the application program to a trustednon-volatile random access memory NVRAM inside the security CPU.

With reference to any one of the first to the third possibleimplementation manners of the first aspect, in a fourth possibleimplementation manner of the first aspect, before the decrypting astored digital signature of the application program according to apublic key in an embedded key pair to obtain the second digest of theapplication program, the method further includes:

obtaining the stored digital signature in the trusted NVRAM by using thesecurity engine inside the security CPU.

According to a second aspect, a network device is provided, and thenetwork device includes:

a first calculation module, configured to perform characteristic valuecalculation on data of an application program when the applicationprogram starts, to obtain a first digest of the application program;

a decryption module, configured to decrypt a stored digital signature ofthe application program according to a public key in an embedded keypair to obtain a second digest of the application program, where thedigital signature is obtained, according to a private key in the keypair, by signing data of the application program each time theapplication program is updated, and the key pair is a manufacturer keypair corresponding to the application program; and

a determining module, configured to determine that integrityverification of the application program passes if the first digest andthe second digest are the same, or determine that integrity verificationof the application program does not pass if the first digest and thesecond digest are different.

With reference to the second aspect, in a first possible implementationmanner of the second aspect, the network device further includes:

a second calculation module, configured to perform characteristic valuecalculation on the data of the application program when receiving anupdate completion instruction, to obtain the second digest of theapplication program;

a signature module, configured to sign the second digest according tothe private key to obtain the digital signature of the applicationprogram; and

a storage module, configured to store the digital signature of theapplication program.

With reference to the first possible implementation manner of the secondaspect, in a second possible implementation manner of the second aspect,the second calculation module includes:

a read-in unit, configured to read the data of the application programin a memory into a static random access memory SRAM inside a securitycentral processing unit CPU;

a reading unit, configured to read the data in the SRAM by using asecurity engine inside the security CPU; and

a calculation unit, configured to perform characteristic valuecalculation on the read data by using the security engine, to obtain thesecond digest of the application program.

With reference to the first possible implementation manner of the secondaspect or the second possible implementation manner of the secondaspect, in a third possible implementation manner of the second aspect,the storage module includes:

a storage unit, configured to store the digital signature of theapplication program to a trusted non-volatile random access memory NVRAMinside the security CPU.

With reference to the first possible implementation manner of the secondaspect or the second possible implementation manner of the second aspector the third possible implementation manner of the second aspect, in afourth possible implementation manner of the second aspect, the networkdevice further includes:

an obtaining module, configured to obtain the stored digital signaturein the trusted NVRAM by using the security engine inside the securityCPU.

In the embodiments of the present disclosure, each time an applicationprogram in a network device is updated, data of the application programis updated. In this case, the network device signs data of theapplication program according to a private key in an embedded key pairto obtain a digital signature of the application program. Characteristicvalue calculation is performed on data of the application program whenthe application program starts, to obtain a first digest of theapplication program, and the digital signature of the applicationprogram is decrypted according to a public key in the key pair to obtaina second digest of the application program. It is determined thatintegrity verification of the application program passes if the firstdigest and the second digest are the same, or it is determined thatintegrity verification of the application program does not pass if thefirst digest and the second digest are different. The manufacturer keypair is embedded in the network device, and the data of the applicationprogram is signed according to the private key in the key pair each timethe network device updates the application program, so that the digitalsignature of the application program is updated, and consequently, thesecond digest is also updated, which ensures that integrity verificationof the application program can be performed after the applicationprogram is updated.

BRIEF DESCRIPTION OF DRAWINGS

To illustrate technical solutions of embodiments of the presentdisclosure more clearly, the following briefly describes theaccompanying drawings required in description of the embodiments.Apparently, the accompanying drawings described below are merely some ofthe embodiments of the present disclosure, and a person of ordinaryskill in the art may still derive other drawings according to theseaccompanying drawings without creative efforts.

FIG. 1 is a flowchart of an application program integrity verificationmethod according to an embodiment of the present disclosure;

FIG. 2 is a flowchart of an application program integrity verificationmethod according to an embodiment of the present disclosure;

FIG. 3 is a schematic diagram of an internal structure of a security CPUaccording to an embodiment of the present disclosure;

FIG. 4 is a schematic structural diagram of a network device accordingto an embodiment of the present disclosure; and

FIG. 5 is a schematic structural diagram of another network deviceaccording to an embodiment of the present disclosure.

DESCRIPTION OF EMBODIMENTS

To make objectives, technical solutions, and advantages of the presentdisclosure clearer, the following further details implementation mannersof the present disclosure with reference to the accompanying drawings.

Before the present disclosure is explained in detail, an applicationscenario of embodiments of the present disclosure is first described. Avillain may tamper with an application program in a network device tosteal user private information such as an account number and a password,which poses a threat to property safety of a user. Therefore, each timethe application program starts, the network device needs to performintegrity verification on the application program, so as to determinewhether the application program is tampered with. However, as time goesby, a vulnerability may exist in the application program of the networkdevice. In this case, patching needs to be performed on the applicationprogram in the network device. Patches are generally distributed onmultiple data fragments of the application program; consequently,integrity verification cannot be performed, according to a method forseparately performing integrity verification on the application programand on the patches, on the application program obtained after patchingis performed. In addition, a stored digital signature in a trustedplatform module (TPM) chip of the network device is obtained based onoriginal data of the application program, and data of the applicationprogram obtained after patching is performed is different from theoriginal data. Therefore, integrity verification cannot be performed,based on the digital signature of the original data, on the applicationprogram obtained after patching is performed. In this case, theembodiments of the present disclosure provide a method for applicationprogram integrity verification, in which the network device may stillperform integrity verification on the application program after patchingis performed on the application program.

FIG. 1 is a flowchart of an application program integrity verificationmethod according to an embodiment of the present disclosure. The methodis executed by a network device, and a manufacturer key paircorresponding to an application program is stored in a trusted locationof the network device. Referring to FIG. 1, the method includes thefollowing steps.

S101: Perform characteristic value calculation on data of theapplication program when the application program starts, to obtain afirst digest of the application program.

In the embodiment of the present disclosure, the characteristic valuecalculation may be hash calculation. Certainly, the characteristic valuecalculation may alternatively be another calculation method, which isnot specifically limited in the embodiment of the present disclosure. Inaddition, when the characteristic value calculation is the hashcalculation, an algorithm of the hash calculation may be a secure hashalgorithm (SHA), an SHA2 algorithm, an SM3 cryptographic hash algorithmof Chinese commercial cryptographic hash algorithm standard published byState Cryptography Administration, or the like, which is notspecifically limited in the embodiment of the present disclosure.

S102: Decrypt a stored digital signature of the application programaccording to a public key in an embedded key pair to obtain a seconddigest of the application program, where the digital signature isobtained, according to a private key in the key pair, by signing data ofthe application program each time the application program is updated,and the key pair is the manufacturer key pair corresponding to theapplication program.

S103: Determine that integrity verification of the application programpasses if the first digest and the second digest are the same, ordetermine that integrity verification of the application program doesnot pass if the first digest and the second digest are different.

In the embodiment of the present disclosure, each time an applicationprogram in a network device is updated, data of the application programis updated. In this case, the network device signs data of theapplication program according to a private key in an embedded key pairto obtain a digital signature of the application program. Characteristicvalue calculation is performed on data of the application program whenthe application program starts, to obtain a first digest of theapplication program, and the digital signature of the applicationprogram is decrypted according to a public key in the key pair to obtaina second digest of the application program. It is determined thatintegrity verification of the application program passes if the firstdigest and the second digest are the same, or it is determined thatintegrity verification of the application program does not pass if thefirst digest and the second digest are different. The manufacturer keypair is embedded in the network device, and the data of the applicationprogram is signed according to the private key in the key pair each timethe network device updates the application program, so that the digitalsignature of the application program is updated, and consequently, thesecond digest is also updated, which ensures that integrity verificationof the application program can be performed after the applicationprogram is updated.

Optionally, before the performing characteristic value calculation ondata of the application program when the application program starts, toobtain a first digest of the application program, the method furtherincludes:

performing characteristic value calculation on the data of theapplication program when receiving an update completion instruction, toobtain the second digest of the application program;

signing the second digest according to the private key in the key pairto obtain the digital signature of the application program; and

storing the digital signature of the application program.

Optionally, the performing characteristic value calculation on the dataof the application program to obtain the second digest of theapplication program includes:

reading the data of the application program in a memory into a staticrandom access memory (SRAM) inside a security CPU;

reading the data in the SRAM by using a security engine inside thesecurity CPU; and

performing characteristic value calculation on the read data by usingthe security engine, to obtain the second digest of the applicationprogram.

Optionally, the storing the digital signature of the application programincludes:

storing the digital signature of the application program to a trustednon-volatile random access memory (NVRAM) inside the security CPU.

Optionally, before the decrypting a stored digital signature of theapplication program according to a public key in an embedded key pair toobtain a second digest of the application program, the method furtherincludes:

obtaining the stored digital signature in the trusted NVRAM by using thesecurity engine inside the security CPU.

All foregoing optional technical solutions may form an optionalembodiment of the present disclosure in any combination, and details arenot described in the embodiment of the present disclosure again.

FIG. 2 is a flowchart of an application program integrity verificationmethod according to an embodiment of the present disclosure. The methodmay be executed by a network device, and a manufacturer key paircorresponding to an application program is stored in a trusted locationof the network device. Referring to FIG. 2, the method includes thefollowing steps.

S201: Perform characteristic value calculation on data of theapplication program when an update completion instruction is received,to obtain a second digest of the application program.

Because a vulnerability may exist in the application program of thenetwork device, the network device needs to perform patching on theapplication program, or a manufacturer upgrades the application program,and the network device needs to upgrade the application program. Whencompleting patching or upgrading of the application program, the networkdevice receives an update completion instruction. The update completioninstruction may be obtained by means of triggering by the networkdevice, or may be obtained by means of triggering by the network devicewhen the network device receives a completion response from a server,where the server is a device storing the application program. Afterupdating the application program in the network device, the data of theapplication program in the network device change. In this case, thesecond digest of the application program needs to be recalculated, andthen the application program is re-signed.

In addition, to further ensure integrity of the application program andprevent a villain from tampering with the application program, asecurity CPU may be disposed in the network device. A diagram of aninternal structure of the security CPU is shown in FIG. 3. The securityCPU includes a security engine, a processor, an SRAM, a key-pair storagedevice, and a trusted NVRAM, where the security engine, the SRAM, thekey-pair storage device, and the trusted NVRAM are all secure andtrusted. The security engine is configured to: read data in the SRAM andprocess the read data; the SRAM is configured to store data of a trustedapplication program; the key-pair storage device is configured to storea manufacturer key pair; the trusted NVRAM is configured to store adigital signature of the application program. Therefore, an operation ofperforming characteristic value calculation on the data of theapplication program to obtain the second digest of the applicationprogram may specifically be: reading the data of the application programin a memory into the static random access memory SRAM inside thesecurity central processing unit CPU by the security CPU; reading thedata in the SRAM by using the security engine inside the security CPU;and performing characteristic value calculation on the read data byusing the security engine, to obtain the second digest of theapplication program.

The security engine may read the data from the SRAM, but the processorcannot read the data from the SRAM, which ensures that the data in theSRAM is not infected, so as to ensure credibility and reliability of thedata. In addition, the characteristic value calculation may be hashcalculation. Certainly, the characteristic value calculation mayalternatively be another calculation method, which is not specificallylimited in the embodiment of the present disclosure. Moreover, when thecharacteristic value calculation is the hash calculation, an algorithmof the hash calculation may be a secure hash algorithm (SHA), an SHA2algorithm, an SM3 cryptographic hash algorithm of Chinese commercialcryptographic hash algorithm standard published by State CryptographyAdministration, or the like, which is not specifically limited in theembodiment of the present disclosure.

It should be noted that, the application program involved in theembodiment of the present disclosure may be an operating system, wherethe operating system may further have an application APP installed.Certainly, the application program may alternatively be a third partyapplication program, which is not specifically limited in the embodimentof the present disclosure. In addition, the network device involved inthe embodiment of the present disclosure may be a network device such asa router, and an operating system of the network device may be anembedded operating system. Certainly, for a device on which a commonoperating system is installed, application program integrityverification may be performed based on a method same as or similar tothe embodiment of the present disclosure. For example, the device onwhich the common operating system is installed may be a computer, amobile phone, a palmtop computer, or the like, which is also notspecifically limited in the embodiment of the present disclosure.

S202: Sign the second digest according to a private key in an embeddedkey pair to obtain a digital signature of the application program, wherethe key pair is the manufacturer key pair corresponding to theapplication program.

Specifically, the security engine obtains the private key in the keypair from the key-pair storage device, and signs the second digestaccording to the obtained private key to obtain the digital signature ofthe application program.

There may be various algorithms of signing the second digest accordingto the obtained private key, such as an RSA, an ElGamal, a Fiat-Shamir,or a Schnorr, and the embodiment of the present disclosure does notspecifically limit the used signature algorithm.

S203: Store the digital signature of the application program.

The digital signature of the application program may be stored to atrusted non-volatile random access memory NVRAM inside the securitycentral processing unit CPU. A region, in the trusted NVRAM, of storingthe digital signature is only allowed to be read by the security enginerather than the processor, which ensures that the region, in the NVRAM,of storing the digital signature is not infected, so as to ensurecredibility and reliability of the stored digital signature.

It should be noted that, when the network device downloads theapplication program for the first time and receives a downloadcompletion instruction, the network device may also calculate thedigital signature of the application program according to a methodsimilar to the method that includes S201 to S203, and store the digitalsignature in the trusted NVRAM. Each time the application program isupdated, the network device signs data of the application programaccording to the private key in the key pair and based on the steps S201to S203, to obtain a digital signature of the application program, andthen replaces the stored digital signature in the trusted NVRAM with thecurrently calculated digital signature of the application program.

In addition, in the embodiment of the present disclosure, the digitalsignature of the application program is not stored to a TPM chip, but isstored to the trusted NVRAM inside the CPU. Therefore, a TPM chip doesnot need to be disposed in the network device, which reduces costs ofapplication program integrity verification.

After the application program in the network device is updated and thedigital signature of the application program is updated according toS201 to S203, the stored digital signature in the network device isobtained by means of signing based on data of the updated applicationprogram, rather than being obtained by means of signing based onoriginal data of the application program, which ensures that the storeddigital signature in the network device is the latest, so as to performintegrity verification on the application program according to S204 toS206.

S204: Perform characteristic value calculation on data of theapplication program when the application program starts, to obtain afirst digest of the application program.

Specifically, when the application program starts, the data of theapplication program in the memory is read into the SRAM inside thesecurity CPU by the security CPU; the data in the SRAM is read by usingthe security engine inside the security CPU; and characteristic valuecalculation is performed on the read data by using the security engine,to obtain the first digest of the application program.

S205: Decrypt the stored digital signature of the application programaccording to a public key in the key pair to obtain the second digest ofthe application program.

The digital signature of the application program may be stored to thetrusted NVRAM inside the security CPU. Therefore, before the decryptingthe stored digital signature of the application program by using thesecurity engine according to a public key in the key pair to obtain thesecond digest of the application program, the method further includes:obtaining the stored digital signature in the trusted NVRAM by using thesecurity engine inside the security CPU, so as to ensure that the storeddigital signature in the trusted NVRAM is not infected.

An algorithm of decrypting the stored digital signature of theapplication according to the public key in the key pair is the same asthe signature algorithm in S202, which is also not specifically limitedin the embodiment of the present disclosure.

S206: Determine that integrity verification of the application programpasses if the first digest and the second digest are the same, ordetermine that integrity verification of the application program doesnot pass if the first digest and the second digest are different.

Specifically, the security engine compares the first digest with thesecond digest. If the first digest and the second digest are the same,it is determined that the application program is not tampered with, andintegrity verification of the application program passes. If the firstdigest and the second digest are different, it is determined that theapplication program is tampered with, and integrity verification of theapplication program does not pass. Further, when it is determined thatthe integrity verification of the application program does not pass, thenetwork device may display prompt information to remind a user that theapplication program is tampered with, so that the user may no longer usethe application program, Therefore, occurrence of security incidents,that is, stealing private information such as an account number and apassword of the user, is prevented.

The calculated second digest in the foregoing S201 is obtained by meansof calculation based on the data of the updated application program,that is, the second digest is a reference digest. If the applicationprogram is tampered with by a villain, the calculated first digest inthe foregoing S204 is obtained by means of calculation based on data ofan application program that has been tampered with. Therefore, integrityverification may be performed on the application program according tothe first digest and the second digest.

In addition, the network device performs digital signature on theapplication program to entirely transfer an integrity protectionmechanism of the application program to the network device side, andintegrity of the application program no longer relies on privacy of amanufacturer private key. In this way, security decoupling isimplemented between a manufacturer and a user, and the manufacturer andthe user no longer rely on each other. Once a villain tampers with theapplication program and a security incident occurs, responsibilities ofthe security incident are relatively clear. Moreover, when patching orupgrading is performed on the application program in the network deviceand the network device is a large telecommunications device, a seriousconsequence is caused once a service is interrupted because thetelecommunications device requires that the ongoing service cannot beinterrupted. Therefore, according to the method provided in theembodiment of the present disclosure, patching or upgrading may beperformed on the application program online, which avoids interrupting aservice running in the telecommunications device.

In the embodiment of the present disclosure, each time an applicationprogram in a network device is updated, data of the application programis updated. In this case, the network device signs data of theapplication program according to a private key in an embedded key pairto obtain a digital signature of the application program. Characteristicvalue calculation is performed on data of the application program whenthe application program starts, to obtain a first digest of theapplication program, and the digital signature of the applicationprogram is decrypted according to a public key in the key pair to obtaina second digest of the application program. It is determined thatintegrity verification of the application program passes if the firstdigest and the second digest are the same, or it is determined thatintegrity verification of the application program does not pass if thefirst digest and the second digest are different. The manufacturer keypair is embedded in the network device, and the data of the applicationprogram is signed according to the private key in the key pair each timethe network device updates the application program, so that the digitalsignature of the application program is updated, and consequently, thesecond digest is also updated, which ensures that integrity verificationof the application program can be performed after the applicationprogram is updated.

FIG. 4 is a schematic structural diagram of a network device accordingto an embodiment of the present disclosure. A manufacturer key paircorresponding to an application program is stored in a trusted locationof the network device. Referring to FIG. 4, the network device includes:a first calculation module 401, a decryption module 402 and adetermining module 403.

The first calculation module 401 is configured to perform characteristicvalue calculation on data of an application program when the applicationprogram starts, to obtain a first digest of the application program.

The decryption module 402 is configured to decrypt a stored digitalsignature of the application program according to a public key in anembedded key pair to obtain a second digest of the application program,where the digital signature is obtained, according to a private key inthe key pair, by signing data of the application program each time theapplication program is updated, and the key pair is the manufacturer keypair corresponding to the application program.

The determining module 403 is configured to: determine that integrityverification of the application program passes if the first digest andthe second digest are the same, or determine that integrity verificationof the application program does not pass if the first digest and thesecond digest are different.

Optionally, the network device further includes:

a second calculation module, configured to perform characteristic valuecalculation on the data of the application program when receiving anupdate completion instruction, to obtain the second digest of theapplication program;

a signature module, configured to sign the second digest according tothe private key in the key pair to obtain the digital signature of theapplication program; and

a storage module, configured to store the digital signature of theapplication program.

Optionally, the second calculation module includes:

a read-in unit, configured to read the data of the application programin a memory into a static random access memory SRAM inside a securitycentral processing unit CPU;

a reading unit, configured to read the data in the SRAM by using asecurity engine inside the security CPU; and

a calculation unit, configured to perform characteristic valuecalculation on the read data by using the security engine, to obtain thesecond digest of the application program.

Optionally, the storage module includes:

a storage unit, configured to store the digital signature of theapplication program to a trusted non-volatile random access memory NVRAMinside the security CPU.

Optionally, the network device further includes:

an obtaining module, configured to obtain the stored digital signaturein the trusted NVRAM by using the security engine inside the securityCPU.

Optionally, when the characteristic value calculation is hashcalculation, an algorithm of the hash calculation may be a secure hashalgorithm (SHA), an SHA2 algorithm, an SM3 cryptographic hash algorithmof Chinese commercial cryptographic hash algorithm standard published byState Cryptography Administration, or the like, which is notspecifically limited in the embodiment of the present disclosure.

In the embodiment of the present disclosure, each time an applicationprogram in a network device is updated, data of the application programis updated. In this case, the network device signs data of theapplication program according to a private key in an embedded key pairto obtain a digital signature of the application program. Characteristicvalue calculation is performed on data of the application program whenthe application program starts, to obtain a first digest of theapplication program, and the digital signature of the applicationprogram is decrypted according to a public key in the key pair to obtaina second digest of the application program. It is determined thatintegrity verification of the application program passes if the firstdigest and the second digest are the same, or it is determined thatintegrity verification of the application program does not pass if thefirst digest and the second digest are different. The manufacturer keypair is embedded in the network device, and the data of the applicationprogram is signed according to the private key in the key pair each timethe network device updates the application program, so that the digitalsignature of the application program is updated, and consequently, thesecond digest is also updated, which ensures that integrity verificationof the application program can be performed after the applicationprogram is updated.

It should be noted that, the division of the foregoing functionalmodules is used merely as an example for describing application programintegrity verification performed by the network device provided in theforegoing embodiment. In actual application, the foregoing functions maybe allocated to different functional modules as required forimplementation, that is, the internal structure of the network device isdivided into different functional modules to complete all or some of theforegoing functions. In addition, the network device provided in theforegoing embodiment belongs to the same concept as method embodimentsof application program integrity verification. For a specificimplementation process of the network device, reference may be made tothe method embodiments, and details are not described herein again.

All foregoing optional technical solutions may form an optionalembodiment of the present disclosure in any combination, and details arenot described in the embodiment of the present disclosure again.

FIG. 5 is a schematic structural diagram of another network deviceaccording to an embodiment of the present disclosure. Referring to FIG.5, the network device includes: a security processor 501 and a trustedmemory 502.

The security processor 501 is configured to: perform characteristicvalue calculation on data of an application program when the applicationprogram starts, to obtain a first digest of the application program;decrypt a stored digital signature of the application program accordingto a public key in an embedded key pair to obtain a second digest of theapplication program, where the digital signature is obtained, accordingto a private key in the key pair, by signing data of the applicationprogram each time the application program is updated, and the key pairis a manufacturer key pair corresponding to the application program;determine that integrity verification of the application program passesif the first digest and the second digest are the same, or determinethat integrity verification of the application program does not pass ifthe first digest and the second digest are different.

Optionally, the security processor 501 is further configured to: performcharacteristic value calculation on the data of the application programwhen receiving an update completion instruction, to obtain the seconddigest of the application program; sign the second digest according tothe private key in the key pair to obtain the digital signature of theapplication program.

The trusted memory 502 is configured to store the digital signature ofthe application program.

Optionally, the security processor 501 is further configured to: readthe data of the application program in a memory into a static randomaccess memory SRAM inside a security central processing unit CPU; readthe data in the SRAM; and perform characteristic value calculation onthe read data to obtain the second digest of the application program.

Optionally, the security central processing unit CPU may be located inthe security processor 501.

Optionally, the security central processing unit CPU may be disposedseparately with the security processor 501.

Optionally, the security processor 501 is further configured to storethe digital signature of the application program to a trustednon-volatile random access memory NVRAM inside the security CPU.

Optionally, the security processor 501 is further configured to obtainthe stored digital signature in the trusted NVRAM.

Optionally, when the characteristic value calculation is hashcalculation, an algorithm of the hash calculation may be a secure hashalgorithm (SHA), an SHA2 algorithm, an SM3 cryptographic hash algorithmof Chinese commercial cryptographic hash algorithm standard published byState Cryptography Administration, or the like, which is notspecifically limited in the embodiment of the present disclosure.

All foregoing optional technical solutions may form an optionalembodiment of the present disclosure in any combination, and details arenot described in the embodiment of the present disclosure again.

In the embodiment of the present disclosure, each time an applicationprogram in a network device is updated, data of the application programis updated. In this case, the network device signs data of theapplication program according to a private key in an embedded key pairto obtain a digital signature of the application program. Characteristicvalue calculation is performed on data of the application program whenthe application program starts, to obtain a first digest of theapplication program, and the digital signature of the applicationprogram is decrypted according to a public key in the key pair to obtaina second digest of the application program. It is determined thatintegrity verification of the application program passes if the firstdigest and the second digest are the same, or it is determined thatintegrity verification of the application program does not pass if thefirst digest and the second digest are different. The manufacturer keypair is embedded in the network device, and the data of the applicationprogram is signed according to the private key in the key pair each timethe network device updates the application program, so that the digitalsignature of the application program is updated, and consequently, thesecond digest is also updated, which ensures that integrity verificationof the application program can be performed after the applicationprogram is updated.

A person of ordinary skill in the art may understand that all or some ofthe steps in the foregoing embodiments may be implemented by hardware,or by a program instructing related hardware. The program may be storedin a computer readable storage medium, and the foregoing storage mediummay be a read-only memory, a magnetic disk, an optical disc, or thelike.

The foregoing is only exemplary embodiments of the present disclosure,which is not intended to limit the present disclosure. Any modification,equivalent replacement and improvement made without departing from thespirit and principal of the present disclosure shall fall within theprotection scope of the present disclosure.

What is claimed is:
 1. A method performed by a trusted security engine,the method comprising: generating, based upon data of an applicationprogram, a first digest of the application program when the applicationprogram starts up; decrypting a digital signature of the applicationprogram according to a public key in a key pair to obtain a seconddigest of the application program, wherein the digital signature isobtained, according to a private key in the key pair, by signing data ofthe application program when the application program has been updatedrecently, and the key pair is a manufacturer key pair corresponding tothe application program; and determining that integrity verification ofthe application program passes if the first digest matches the seconddigest.
 2. The method according to claim 1, wherein the second digest isobtained by performing a characteristic value calculation on data of theapplication program when the application program starts up.
 3. Themethod according to claim 2, wherein the characteristic valuecalculation on the data of the application program is performed in astatic random access memory (SRAM) inside a security central processingunit (CPU) in which the trusted security engine is located.
 4. Themethod according to claim 2, wherein the characteristic valuecalculation on the data of the application program is performed by usingone of: an SM3 cryptographic hash algorithm of Chinese commercialcryptographic hash algorithm standard published by State CryptographyAdministration, a secure hash algorithm (SHA), an SHA2, anRivest-Shamir-Adleman (RSA) algorithm, an ElGamal algorithm, aFiat-Shamir algorithm, and a Schnorr algorithm.
 5. The method accordingto claim 2, wherein before the performing the characteristic valuecalculation on the data of the application program, the method furthercomprises: performing the characteristic value calculation on the dataof the application program when receiving an update completioninstruction, to obtain the second digest of the application program;signing the second digest according to the private key to obtain thedigital signature of the application program; and storing the digitalsignature of the application program.
 6. The method according to claim1, wherein the digital signature is read only by the trusted securityengine.
 7. The method according to claim 1, wherein the digitalsignature is stored in a trusted non-volatile random access memory(NVRAM).
 8. The method according to claim 1, wherein the key pair isembedded in a device including the security engine.
 9. The methodaccording to claim 1, wherein the data of the application programcomprises a patch including a plurality of data fragments of theapplication program.
 10. The method according to claim 1, wherein themethod is performed when patching or updating the application programwithout interrupting a service related with the application program. 11.A device, comprising a processor, communicably coupled with a memorystoring computer executable program codes, wherein the program codescomprise instructions that, when executed by the processor, cause theprocessor to: generate, based upon data of an application program, afirst digest of the application program when the application programstarts up; decrypt a digital signature of the application programaccording to a public key in a key pair to obtain a second digest of theapplication program, wherein the digital signature is obtained,according to a private key in the key pair, by signing data of theapplication program when the application program has been updatedrecently, and the key pair is a manufacturer key pair corresponding tothe application program; and determine that integrity verification ofthe application program passes if the first digest matches the seconddigest.
 12. The device according to claim 11, wherein the second digestis obtained by performing a characteristic value calculation on data ofthe application program when the application program starts up.
 13. Thedevice according to claim 11, wherein the processor is a securitycentral processing unit (CPU) comprising a static random access memory(SRAM) involving a security engine.
 14. The device according to claim12, wherein the characteristic value calculation on the data of theapplication program is performed by using one of: an SM3 cryptographichash algorithm of Chinese commercial cryptographic hash algorithmstandard published by State Cryptography Administration, a secure hashalgorithm (SHA), an SHA2, an Rivest-Shamir-Adleman (RSA) algorithm, anElGamal algorithm, a Fiat-Shamir algorithm, and a Schnorr algorithm. 15.The device according to claim 12, wherein the program codes furthercomprise instructions that, when executed by the processor, cause theprocessor to: before the performing the characteristic value calculationon the data of the application program, sign the second digest accordingto the private key to obtain the digital signature of the applicationprogram; and store the digital signature of the application program. 16.The device according to claim 11, wherein the memory comprises a staticrandom access memory (SRAM) involving a security engine.
 17. The deviceaccording to claim 16, wherein the security engine is in a securitycentral processing unit (CPU).
 18. The device according to claim 16,wherein the digital signature is read only by the security engine.
 19. Anon-transitory computer-readable storage medium comprising computerexecutable program codes, wherein the program codes compriseinstructions that, when executed by a computer, cause the computer to:generate, based upon data of an application program, a first digest ofthe application program when the application program starts up; decrypta digital signature of the application program according to a public keyin a key pair to obtain a second digest of the application program,wherein the digital signature is obtained, according to a private key inthe key pair, by signing data of the application program when theapplication program has been updated recently, and the key pair is amanufacturer key pair corresponding to the application program; anddetermine that integrity verification of the application program passesif the first digest matches the second digest.
 20. The non-transitorycomputer-readable storage medium according to claim 19, wherein thesecond digest is obtained by performing a characteristic valuecalculation on data of the application program when the applicationprogram starts up.
 21. The non-transitory computer-readable storagemedium according to claim 20, further comprising instructions that, whenexecuted by the computer, further cause the computer to: before theperforming the characteristic value calculation on the data of theapplication program, sign the second digest according to the private keyto obtain the digital signature of the application program; and storethe digital signature of the application program.